package com.lixixi.tingshu.album;

import com.lixixi.tingshu.common.constant.RedisConstant;
import org.mybatis.spring.annotation.MapperScan;
import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

@SpringBootApplication
@EnableDiscoveryClient
@MapperScan("com.lixixi.tingshu.*.mapper")
@ComponentScan("com.lixixi.tingshu")
@EnableFeignClients(basePackages = "com.lixixi.tingshu.*.api") //启用feign客户端,定义服务+绑定接口，以声明式的方法优雅而简单的实现服务调用
@EnableAspectJAutoProxy
public class AlbumMain8555 implements CommandLineRunner {
	@Autowired
	RedissonClient redissonClient;

	public static void main(String[] args) {
		SpringApplication.run(AlbumMain8555.class, args);
	}


	@Override
	public void run(String... args) throws Exception {
		//初始化专辑布隆过滤器
		RBloomFilter<Object> bloomFilter = redissonClient.getBloomFilter(RedisConstant.ALBUM_BLOOM_FILTER);
		//设置数据规模 误判率 预计统计元素数量为100000，期望误差率为0.01
		bloomFilter.tryInit(100000, 0.01);
	}
}
